package com.woniuxy.sys.controller;
import com.woniuxy.sys.entity.StoreInfo;
import com.woniuxy.sys.service.IStoreInfoService;
import io.swagger.annotations.Api;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 *
 */
@RestController
@RequestMapping("/store")
@Api("仓库系统控制器")
public class StoreInfoController {

    @Autowired
    private IStoreInfoService storeInfoService;
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 查询所有仓库
     */
    @GetMapping("/")
    public List<StoreInfo> getAllStore(){
        List storeInfoList = redisTemplate.opsForList().range("storeList",0,-1);
        return storeInfoList;
    }

    /**
     * 添加仓库地址
     */
    @PostMapping("/")
    private String addStore(StoreInfo storeInfo){
        String result = storeInfoService.addStore(storeInfo);
        return result;
    }

}
